/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import entity.Room;
import entity.Slot;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import manager.RoomManager;
import manager.SlotManager;
import manager.StudentManager;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;

/**
 *
 * @author daz
 */
public class SlotController extends SimpleFormController {

    private SlotManager slotManager;

    public SlotController() {
        setCommandClass(Slot.class);
        setCommandName("slotForm");
    }

    public void setSlotManager(SlotManager slotManager) {
        this.slotManager = slotManager;
    }

    public SlotManager getSlotManager() {
        return slotManager;
    }

    @Override
    protected ModelAndView onSubmit(HttpServletRequest request,
            HttpServletResponse response, Object command, BindException errors)
            throws Exception {
        Slot s = (Slot) command;
        this.slotManager.insertNewSlot(s);
        return new ModelAndView("SlotSucess", "slot", s);

    }
}
